package com.gagakuai.bpm.domian.entity.camuda;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/*
 * @program: mss_server
 * @description: 用于获取新的entity
 * @author: houhong
 * @create: 2022-03-14 14:47
 */
@Data
@Accessors(chain = true)
public class WorkflowTaskEntityNew implements Serializable {

    private String taskId;


    private String procInstId;

    private String procDefId;

    private String procDefName;

    private String executionId;


    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date followUpDate;

    private String parentTaskId;

    private Boolean suspensionState;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endTime;

    private String tenantId;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;


    private String first;

    /*
     * 流程定义中文名
     */
    private String processName;
    /*
     * 流程定英文名
     */
    private String processEnName;

    /*
     * 具体业务key
     */
    private String businessKey;

    /*
     * 当前环节
     */
    private String curTaskName;

    /*
     *
     * 发起人
     */
    private String startUserId;


    /*
     * 到期时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date dueDate;


    /*
     * 任务持续时间
     */
    private Long duration;


    /*
     * 剩下时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date leftDate;

    /*
     * 委托人
     */
    private String owner;

    /*
     * 办理人
     */
    private String assignee;

    /*
     * 委托状态
     */
    private String delegation;

    /*
     * 任务描述
     */
    private String description;

    /*
     * 优先级
     */
    private int priority;


    /*
     * 任务定义key
     */
    private String taskDefKey;


    /*
     * 办理意见
     */
    private String proposal;

    /*
     * 父亲节点状态中文
     */
    private String parentStstusZn;

    /*
     * 父亲节点状态
     */
    private Integer parentStatus;

    /*
     * 数据是否可被编辑
     */
    private Boolean isEdited;

    /*
     * 节点状态
     */
    private String status;

    /*
     * 流程实列状态
     */
    private String state;


    /*
     * 是否结束
     */
    private String isFinished;

    //重写hashcode hashcode不相等 则两个对象一定不相等
    @Override
    public int hashCode() {
        int n = 31;
        //流程定义key
        n = n * 31 + this.processEnName.hashCode();
        //节点定义id
        n = n * 31 + this.taskDefKey.hashCode();
        //发起人
        n = n * 31 + this.startUserId.hashCode();
        //创建时间
        n = n * 31 +  new Long(this.startTime.getTime()).hashCode();;

        return n;
    }


    @Override
    public boolean equals(Object obj) {

        WorkflowTaskEntityNew test = (WorkflowTaskEntityNew) obj;

        if (obj == this) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (obj instanceof WorkflowTaskEntityNew) {


            return this.processEnName.equals(test.processEnName)
                    && this.taskDefKey.equals(test.taskDefKey)
                    && this.startUserId.equals(test.startUserId)
                    && this.startTime.getTime() == (test.startTime.getTime());
        }

        return false;

    }
}